/*
 * acm2475.c
 *
 *  Created on: 5 Apr 2010
 *      Author: xuxu
 */

#include<stdio.h>
#include<stdlib.h>

int n;
int node[101][2];
int mark[10001];
int bo;

int findcircle(int nownode)
{
	int i;
	if(1==bo)
		return 1;
	if(mark[nownode])
		return 1;
	mark[nownode]=1;
	for(i=0;i<n;i++)
	{
		if(nownode==node[i][0]&&node[i][0]!=node[i][1])
		{
			if(findcircle(node[i][1]))
			{
				mark[nownode]=0;
				bo=1;
				return 1;
			}

		}
	}
	mark[nownode]=0;
	return 0;
}

int main()
{
	int i,j;
	int f;
	while(scanf("%d",&n))
	{
		if(-1==n)
			break;
		for(i=0;i<n;i++)
			scanf("%d%d",&node[i][0],&node[i][1]);
		scanf("%d",&f);
		memset(mark,0,sizeof(mark));
		bo=0;
		if(findcircle(f))
			printf("No\n");
		else
			printf("Yes\n");
	}
	return 0;
}
